function grep = gs_dtmrep(xmi,xma,ymi,yma,nx,ny,dx,dy,zmi,zma,nature)
%
%grep = gs_dtmrep(xmi,xma,ymi,yma,nx,ny,dx,dy,zmi,zma,nature);
%
% This function generates a DTM report, in which
%
%   xmi, ymi: down-left corner of the reference grid;
%   xma, yma: top-right corner of the reference grid;
%   nx, ny  : numbers of grid elments along x,y;
%   dx, dy  : x-,y-grid pass.
%   zmi, zma: extremes of the Z range
%   nature  : string that specifies the nature of the DTM (initial,
%             modified,...)
%
% It is called by GS_GRIDDTM.

% G. Teza, 2006

if nargin < 11, help gs_dtmrep, error('Not enough input data'); end

sdfx = nu_dd(xmi,2);  % Ancillary function, see below
sdfy = nu_dd(ymi,2);
sdlx = nu_dd(xma,2);
sdly = nu_dd(yma,2);
sddx = nu_dd(dx,2);
sddy = nu_dd(dy,2);
sdzi = nu_dd(zmi,2);
sdza = nu_dd(zma,2);
grep = sprintf(...
    '%s%s%s\n\n%s\n %s(%s,%s) m, %s(%s,%s) m;\n\n%s\n%s%d, %s%d;\n\n%s\n%s%s m, %s%s m;\n\n%s%s m%s%s m.',...
    ' === ',nature, ' DTM REPORT ===',...
    'VERTICES:','FIRST:',sdfx,sdfy,'LAST:',sdlx,sdly,...
    'NUMBER OF GRID ELEMENTS:',' nx = ',nx,' ny = ',ny,...
    'GRID SPACING:',' dx = ',sddx,' dy = ',sddy,...
    'ELEVATION RANGE: FROM ',sdzi, ' TO ',sdza);

%--- ancillary function ---
function rd = nu_dd(r,nd)
% For the representation of a number as
% '%nip.ndf', in which nip is the number of digits
% of its integer part and nf is the number of decimals.
srd = ['%' num2str(length(num2str(fix(r)))) '.' num2str(nd) 'f'];
     % (The result is the format for the representation)
rd = sprintf(sprintf('%s',srd),r);
%--- end function